<?php
include"config.php";

if (!empty($_FILES["picture"]["tmp_name"])){
	$jenis_gambar = $_FILES['picture']['type'];
	//echo $jenis_gambar;
	$namafolder="assets/picture/";
	$item_name=$_POST['item_name'];
	$cattegory = $_POST['cattegory'];
	$mark = $_POST['mark'];
	$one_day = $_POST['one_day'];
	$three_day = $_POST['three_day'];
	$seven_day = $_POST['seven_day'];
	$thirty_day = $_POST['thirty_day'];
	$description = $_POST['description'];
	$status = $_POST['status'];
	if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png"){
		//echo"a";
		$gambar = $namafolder . basename($_FILES['picture']['name']);
		$judul_gambarnya = $_FILES['picture']['name'];
		if (move_uploaded_file($_FILES['picture']['tmp_name'], $gambar)){
			//echo"b";
			$sql="insert into tbl_item(id_item, picture, item_name, cattegory, mark, one_day, three_day, seven_day, thirty_day, description, status)values('', '$judul_gambarnya', '$item_name', '$cattegory', '$mark', '$one_day', '$three_day', '$seven_day', '$thirty_day', '$description', '$status')";
			$res=mysql_query($sql) or die (mysql_error());
			
			header("location:index.php?page=item");
		}else{
			echo "Gambar gagal dikirim";
		}
	}else{
		echo "Jenis gambar yang anda kirim salah. Harus .jpg .gif .png";
}
		}else{
			echo "Anda belum memilih gambar";
		}
?>